package com.excellence.controller;

import com.excellence.datamodel.Result;
import com.excellence.service.FileToPhotoService;
import com.excellence.utils.SaveFilesPath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName fileToPhotoController
 * @Description TODO
 * @date 2024/5/5 17:30
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/fileToPhoto")
public class FileToPhotoController {
    @Autowired
    private FileToPhotoService fileToPhotoService;


    //上传单个文件
    @PostMapping("/fileToPhoto")
    public Result fileToPhoto(MultipartFile file) {
        return Result.success(fileToPhotoService.fileToPhoto(file));
    }

    //一次上传多个文件
    @PostMapping("/files")
    public Result files(List<MultipartFile> files) {
        System.out.println(SaveFilesPath.saveFilesPath(files));
        return Result.success(SaveFilesPath.saveFilesPath(files));
    }

}
